package tech.aistar.corejava.day14;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

/**
 * Created by 豆梦寒 on 2019/8/2.
 */
public class PrintWriterDemo {
    public static void main(String[] args) {
        //自带缓冲区功能
        PrintWriter out = null;

        try {
            //不自动刷新缓冲区
           // out = new PrintWriter(new FileWriter("Writer.txt"));
            //自动刷新缓冲区
           // out = new PrintWriter(new FileWriter("Writer.txt"),true);
            //1.自动刷新 - 2. 追加写入
            //第一个true - 是否追加写入 FileWriter(String pathname,boolean append);
            //第二个true - 是否自动刷新缓存 PrintWriter(Writer w,boolean autoFlush);
            out = new PrintWriter(new FileWriter("Writer.txt",true),true);
            //换行
            //out.write("worls\n");
            out.println("hello");
            //手动刷新
            //out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
